package com.vitabuybuy.tv.ui.mine.adapter

import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import com.library.common.widget.RecycleViewDivider
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ItemFootDateBinding
import com.vitabuybuy.tv.dto.MyFootPrintListDto
import com.library.common.base.BindRecycAdapter

class FootDateAdapter : BindRecycAdapter<ItemFootDateBinding, MyFootPrintListDto>() {

    private lateinit var footPrintAdapter: FootPrintAdapter

    override fun onBindViewHolder(
        mBinding: ItemFootDateBinding,
        itemData: MyFootPrintListDto,
        holder: RecyclerView.ViewHolder,
        position: Int
    ) {
        mBinding.tvDate.text = itemData.createDate
        footPrintAdapter = FootPrintAdapter()
        mBinding.listview.apply {
            adapter = footPrintAdapter
            layoutManager = LinearLayoutManager(mContext)
            addItemDecoration(RecycleViewDivider(mContext, 1))
        }
        footPrintAdapter.setNewData(itemData.footprintList)
        footPrintAdapter.onClickChlidDelete = {
            onClickDelete.invoke(position, it)
        }
    }

    lateinit var onClickDelete: (parentPos: Int, childPos: Int) -> Unit


    override fun normalViewId(viewType: Int): Int {
        return R.layout.item_foot_date
    }
}
